//
//  HairShowCell.m
//  MeiXiu
//
//  Created by Yuan on 12-10-30.
//
//

#import "HairShowCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation HairShowCell
@synthesize iconButton;
@synthesize aliasLable; //昵称
@synthesize timeLbl; //时间
@synthesize commentCountLbl; //评论
@synthesize commentButton;
@synthesize likeCountLbl; //喜欢
@synthesize likeButton;
@synthesize contentLbl;//第二行的内容
@synthesize pictureThumbButton;
@synthesize topImageViewbg;

-(void)dealloc
{
    [topImageViewbg release];topImageViewbg = nil;
    [aliasLable release];aliasLable = nil;
    [timeLbl release];timeLbl = nil;
    [commentCountLbl release];commentCountLbl = nil;
    [likeCountLbl release];likeCountLbl = nil;
    [contentLbl release];contentLbl = nil;
    
    [pictureThumbButton release];pictureThumbButton = nil;
    
    [super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        topImageViewbg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320,54)];
        [topImageViewbg setImage:[UIImage imageNamed:@"proshow_userinfo_top.png"]];
        [self.contentView addSubview:topImageViewbg];
        
        CGFloat margin_top = 7.0f;
        
        iconButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [iconButton setFrame:CGRectMake(10,margin_top, 40,40)];
        iconButton.layer.cornerRadius = 6.0;
        [iconButton setUserInteractionEnabled:YES];
        iconButton.layer.masksToBounds = YES;
        [self.contentView addSubview:iconButton];
        
        aliasLable = [[UILabel alloc]initWithFrame:CGRectMake(60.0f, margin_top-2.0, 105.0f, 25.0f)];
        [aliasLable setTextColor:[UIColor colorWithRed:0.720 green:0.225 blue:0.165 alpha:1.000]];
        [aliasLable setFont:[UIFont boldSystemFontOfSize:16.0]];
        [aliasLable setContentMode:UIViewContentModeScaleAspectFit];
        [aliasLable setBackgroundColor:[UIColor clearColor]];
        [aliasLable setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:aliasLable];
        
        timeLbl = [[UILabel alloc]initWithFrame:CGRectMake(60.0f, 28, 100.0f, 18.0f)];
        [timeLbl setTextColor:[UIColor grayColor]];
        [timeLbl setFont:[UIFont systemFontOfSize:12.0]];
        [timeLbl setContentMode:UIViewContentModeScaleAspectFit];
        [timeLbl setBackgroundColor:[UIColor clearColor]];
        [timeLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:timeLbl];
       
        commentCountLbl = [[UILabel alloc]initWithFrame:CGRectMake(207.0f,25.0, 40.0f, 24.0f)];
        [commentCountLbl setTextColor:[UIColor grayColor]];
        [commentCountLbl setFont:[UIFont systemFontOfSize:14.0]];
        [commentCountLbl setContentMode:UIViewContentModeScaleAspectFit];
        [commentCountLbl setTextAlignment:UITextAlignmentLeft];
        [commentCountLbl setBackgroundColor:[UIColor clearColor]];
        [commentCountLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:commentCountLbl];
        
        commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [commentButton setFrame:CGRectMake(180,13.0,31, 27)];
        [commentButton setImage:[UIImage imageNamed:@"proshow_userinfo_comment.png"] forState:UIControlStateNormal];
        [commentButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:commentButton];
        
        
        likeCountLbl = [[UILabel alloc]initWithFrame:CGRectMake(270, 25.0, 40.0f, 24.0f)];
        [likeCountLbl setTextColor:[UIColor grayColor]];
        [likeCountLbl setFont:[UIFont systemFontOfSize:14.0]];
        [likeCountLbl setContentMode:UIViewContentModeScaleAspectFit];
        [likeCountLbl setTextAlignment:UITextAlignmentLeft];
        [likeCountLbl setBackgroundColor:[UIColor clearColor]];
        [likeCountLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:likeCountLbl];
        
        likeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [likeButton setFrame:CGRectMake(250,13.0,31, 27)];
        [likeButton setImage:[UIImage imageNamed:@"proshow_userinfo_like.png"] forState:UIControlStateNormal];
        [likeButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:likeButton];
        
        contentLbl = [[UITextView alloc] initWithFrame:CGRectMake(5.0f,54.0f, 290.0f,80.0f)];
        [contentLbl setEditable:NO];
        [contentLbl setTextColor:[UIColor darkGrayColor]];
        [contentLbl setUserInteractionEnabled:NO];
        [contentLbl setBackgroundColor:[UIColor clearColor]];
        [self.contentView addSubview:contentLbl];
        

//        pictureThumbButton = [UIButton buttonWithType:UIButtonTypeCustom];
        pictureThumbButton = [[UIImageView alloc]init];
        pictureThumbButton.layer.borderWidth = 6.0f;
        pictureThumbButton.layer.borderColor =[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0].CGColor;
        pictureThumbButton.backgroundColor = [UIColor whiteColor];
        [pictureThumbButton setFrame:CGRectMake(90.0f,138.0f,200,238)];
        [pictureThumbButton setClipsToBounds:YES];
        [pictureThumbButton setContentMode:UIViewContentModeScaleAspectFill];
        
        [pictureThumbButton setImage:[UIImage imageNamed:@"loading_default_img.jpg"]];
        
//        [pictureThumbButton setImage:[UIImage imageNamed:@"loading_default_img.jpg"] forState:UIControlStateNormal];
//        [pictureThumbButton setImage:[UIImage imageNamed:@"loading_default_img.jpg"] forState:UIControlStateHighlighted];
        [pictureThumbButton setHidden:NO];
        [self.contentView addSubview:pictureThumbButton];
        
        // Initialization code
    }
    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGRect cRect = contentLbl.frame;
    cRect.size.height = contentLbl.contentSize.height;
    contentLbl.frame = cRect;
    
    CGRect pFrame = pictureThumbButton.frame;
    CGFloat offsetx = (self.contentView.frame.size.width-pFrame.size.width)/2;
    CGFloat offsety = cRect.origin.y+cRect.size.height+5.0f;
    pFrame.origin.x = offsetx;
    pFrame.origin.y = offsety;
    [pictureThumbButton setFrame:pFrame];
    pictureThumbButton.layer.borderWidth = 6.0f;
    pictureThumbButton.layer.borderColor =[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0].CGColor;
    pictureThumbButton.layer.shadowRadius = 4.0;
    pictureThumbButton.layer.shadowColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.9].CGColor;
    pictureThumbButton.layer.shadowPath=[UIBezierPath bezierPathWithRect:pictureThumbButton.bounds].CGPath;
    pictureThumbButton.layer.shadowOffset=CGSizeMake(0.0f, 0.0f);
    pictureThumbButton.layer.shadowOpacity = 1.0;
    pictureThumbButton.layer.shouldRasterize = YES;
    pictureThumbButton.layer.cornerRadius = 4.0f;
    pictureThumbButton.layer.masksToBounds = YES;
    
    self.clipsToBounds = YES;
    CGRect rect = self.contentView.frame;
    rect.size.height  = self.frame.size.height;
    self.contentView.frame = rect;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
